function HashTable(){
  this.storage = []
  this.count = 0
  this.limit = 7

  HashTable.prototype.hashFunc = (str, size)=>{
    var hashCode = 0
    for(var i=0; i<str.length; i++){
      hashCode = 37 * hashCode +str.charCodeAt(i)
    }
    var index = hashCode % size
    return index
  }
  HashTable.prototype.put = (key, value)=>{
    var index = this.hashFunc(key, this.limit)
    var bucket = this.storage[index]
    if(bucket == null){
      bucket = []
      this.storage[index] = bucket
    }
    for(var i=0; i<bucket.length; i++){
      var tuple = bucket[i]
      if(tuple[0] == key){
        tuple[1] = value
        return 
      }
    }
    bucket.push([key, value])
    this.count += 1
  }

  HashTable.prototype.get = (key)=>{
    var index = this.hashFunc(key, this.limit)
    var bucket = this.storage[index]
    if(bucket == null){
      return null
    }
    for(var i=0; i<bucket.length; i++){
      var tuple = bucket[i]
      if(tuple[0] == key){
        return tuple[1]
      }
    }

    return null
  }

  HashTable.prototype.remove = (key)=>{
    var index = this.hashFunc(key, this.limit)
    var bucket = this.storage[index]
    if(bucket == null) return null
    for(var i=0; i<bucket.length; i++){
      var tuple = bucket[i]
      if(tuple[0] == key){
        bucket.splice(i, 1)
        this.count--
        return tuple[1]
      }
    }
  }

  HashTable.prototype.isEmpty = ()=>{
    return this.count == 0
  }

  HashTable.prototype.size = ()=>{
    return this.count
  }
}

var ht = new HashTable()
ht.put('abc', '123')
ht.put('cba', '321')
ht.put('nba', '521')
ht.put('mba', '520')
ht.get('abc')
ht.put('abc', '111')
ht.get('abc')
ht.remove('abc')
ht.get('abc')